package tuse.components.tuseViewer
{
	import UIFree.controls.uif_label;
	import UIFree.uif_transition;
	
	import flash.events.Event;
	import flash.geom.Rectangle;
	
	import tuse.components.ts_component;
	import tuse.components.ts_elipse;
	import tuse.components.tuseViewer.comment.ts_particle;

	public class ts_comment extends ts_elipse {
		private var _particles			: ts_component;
		private var _name				: uif_label;
		private var _description		: uif_label;
		private var _pulseVar			: Number;
		private const PARTCOUNT			: uint = 1; 
		
		public function ts_comment(parent: ts_actor) {
			super(parent, (parent.width - 280) / 2, -190, 280, 250, 'comment');
			var inner: Rectangle = getInner();
			_particles = new ts_component(this, inner.x, inner.y, inner.width, inner.height);
			
			for (var i:int=0; i<PARTCOUNT; i++) {
				var size: Number = 10 + Math.random() * 70;
				new ts_particle(_particles, Math.random() * (width - size / 2), 
											Math.random() * (textBottom - size / 2), size, size, 'compart');
			}
			
			createFields();
			_name.text = parent.info.name;
			_description.text = parent.info.description;
			
			_pulseVar = 0;
			addEvent(Event.ENTER_FRAME, doFrame);
		}
		
		protected function createFields(): void {
			var inner: Rectangle = getInner();
			_name 			= new uif_label(this, inner.x, inner.y, inner.width, 30, style['name']);
			_description 	= new uif_label(this, inner.x, inner.y + 30, inner.width, inner.height - 60, style['description']);
		}
		
		protected function doFrame(e: Event): void {
			if (visible) {
				_pulseVar += 0.2;
				_particles.scaleCenter = 1 + Math.sin(_pulseVar) * 0.1;
				scaleCenter = 1 + Math.sin(_pulseVar * 0.8) * 0.1;
			}			
		}
	}
}